/*
 * Record.h
 *
 * This C++ header file defines some data and operating
 * interfaces for our Record.
 */
#ifndef _RECORD_H
#define _RECORD_H

#include "arch/ia32/IA32ProcessorState.h"
using namespace crossbit;

namespace g_crossbit 
{
   /*
    * This class records some information of data
    * that will be copied from main memory to gpu's 
    * memory or be copied out from gpu's memory to
    * main memory and defines some interfaces which
    * operate on their data.
    */
   class Record 
   {
   public:
	  /* Default constructor */
	  Record ();
      /* Specified constructor */
      Record (short, unsigned int, int, const char *, int, short);
      /* Get direction. */
      short getDirection ();
      /* Get start_addr. */
      unsigned int getStartAddr ();
	  /* Get offset */
	  int getStartOffset();
   	  /* Get gpu_label */
   	  const char *getLabel ();
      /* Get length */
      int getLength ();
      /* Get data_type */
      short getDataType ();

	  bool operator<(const Record &a) const
	  {
		  return (this->direction < a.direction);
	  }

   public:
      static Record *record_ptr; /* Points to start address of records  */
      static int    record_num;  /* Total number of records             */
      static int    record_in;   /* Total number of records whose data
                                  will be copied from Memory to GPU  */
   public:
      /* Load records from a specified file */
      static void loadRecords (const char *, IA32ProcessorState *);
      /* Get a specified records */
      static Record *getRecord (unsigned int, short);
	  /* Display all entries pointed by record_ptr. */
	  static void dumpRecords ();
      /* Free records from main memory */
      static void freeRecords ();
   private:
      short        direction;    /* flow direction of data that will be copied */
      unsigned int start_addr;   /* start address of data or register's number */
      int          start_off;    /* offset based on start_addr         */
	  char         label[10];    /* data's location in gpu's memory    */
      int          length;       /* length of data                     */
      short        data_type;    /* data's type, such as loop index, 
									matrix's length, width...          */
   };

}

#endif
